﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.VisualStudio.VCProjectEngine;
using EnvDTE;

using iMainAddin;

namespace iProjectAddin
{
    public class iModuleDoucmentItem
    {
        public String projectName;
        public String removeExeFileName;
        public ProjectItem fileItem;
        public iModuleDoucmentItem(String project, String file, ProjectItem item)
        {
            projectName = project;
            removeExeFileName = file;
            fileItem = item;
        }
    }
    public class iModuleDoucment
    {
        iModuleDoucmentItem m_Item;
        ExchangeDocument changeFile = new ExchangeDocument();

        public iModuleDoucment(iModuleDoucmentItem item)
        {
            m_Item = item;
            Init();
        }

        public void Init()
        {
            changeFile.AddDictionary("$(ProjectName)", m_Item.projectName);
            changeFile.AddDictionary("$(ProjectNameUP)", m_Item.projectName.ToUpper());
            changeFile.AddDictionary("$(FileName)", m_Item.removeExeFileName);
            changeFile.AddDictionary("$(FileNameUp)", m_Item.removeExeFileName.ToUpper());
        }
        public bool StartChange()
        {
            TextDocument document = m_Item.fileItem.Document.Object("TextDocument") as TextDocument;
            if (document == null)
                return false;
            
            return changeFile.Exchange(document.StartPoint, document.EndPoint);
        }
    }
}
